package com.hongye.proprietary.controller;

import java.util.Arrays;
import java.util.Map;

import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hongye.proprietary.entity.GroupUserRelationshipEntity;
import com.hongye.proprietary.service.GroupUserRelationshipService;
import com.hongye.common.utils.PageUtils;
import com.hongye.common.utils.R;

import javax.servlet.http.HttpSession;


/**
 * 团购用户中间表
 *
 * @author lins
 * @email 695565697@qq.com
 * @date 2021-10-14 11:16:47
 */
@RestController
@RequestMapping("proprietary/groupuserrelationship")
public class GroupUserRelationshipController {
    @Autowired
    private GroupUserRelationshipService groupUserRelationshipService;






    /*
    报名接口
     */
    @RequestMapping("/signup")
    public R signup(@RequestBody GroupUserRelationshipEntity groupUserRelationship, HttpSession session){
       R  signup= groupUserRelationshipService.signup(groupUserRelationship,session);
       return R.ok().put("data",signup);
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = groupUserRelationshipService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		GroupUserRelationshipEntity groupUserRelationship = groupUserRelationshipService.getById(id);

        return R.ok().put("groupUserRelationship", groupUserRelationship);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody GroupUserRelationshipEntity groupUserRelationship){


		groupUserRelationshipService.save(groupUserRelationship);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody GroupUserRelationshipEntity groupUserRelationship){
		groupUserRelationshipService.updateById(groupUserRelationship);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		groupUserRelationshipService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
